/**
 * Copyright (c) 华南农业大学信息学院蔡超敏2015版权所有
 * 
 * 文件创建时间：2015年7月2日
 */
package org.scauinfo.fpos.service.impl;

import java.io.Serializable;
import java.util.List;

import org.scauinfo.fpos.dao.impl.DiscountDao;
import org.scauinfo.fpos.service.DiscountService;
import org.scauinfo.fpos.vo.Discount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 蔡超敏
 * 
 */
@Service
public class DiscountServiceImpl implements DiscountService {
	@Autowired
	private DiscountDao discountDao;

	@Override
	public void saveDiscount(Discount discount) {
		discountDao.save(discount);
	}

	@Override
	public void updateDiscount(Discount discount) {
		discountDao.update(discount);
	}

	@Override
	public void deleteDiscount(int id) {
		Discount discount = discountDao.get(id);
		discountDao.delete(discount);
	}

	@Override
	public List<Discount> findAllDiscount(int page, int rows, String sort,
			String order) {
		return discountDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return discountDao.countAll();
	}

	@Override
	public boolean isExist(String discountId) {
		boolean flag = false;
		String hql = "from Discount as p where p.discountId=" + discountId;
		if (discountDao.find(hql).size() > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public Discount get(Serializable id) {
		return discountDao.get(id);
	}

	@Override
	public List<Discount> findAllDiscount() {
		return discountDao.findAll();
	}
}